using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraGrid.Design;
using DevExpress.XtraGrid;

namespace DXEasyAccount.Common
{
    public class MyGridControlDesigner : GridControlDesigner
    {
        private GridControl _Grid;
        public MyGridControlDesigner(GridControl grid)
        {
            _Grid = grid;
        }

        public override Control Control
        {
            get
            {
                return _Grid;
            }
        }


        public override void ShowDesigner(DevExpress.XtraGrid.Views.Base.BaseView view, string activeItem)
        {
            if (DebuggingStateCheckHelper.PreventDebuggingCrashWhileDebugging(this.Grid, false)) return;
            if (Grid == null) return;
            if (Editor == null)
            {
                Editor = new MyDesignerForm();
            }
            try
            {
                if (view == null && activeItem == null)
                {
                    Editor.InitGrid(Grid);
                }
                else
                {
                    Editor.InitGrid(Grid, activeItem, view);
                }
                //if (Grid.FindForm() != null)
                //    Grid.FindForm().AddOwnedForm(Editor);
                //Editor.();
            }
            finally
            {
                Editor = null;
                UpdateLevelSelector(true);
            }
        }
    }
}